﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Cn.Edwon.Web.ExtControl {
    public class CrudDeleteColumnTemplate :ITemplate {
        #region ITemplate 成员

        private String _CtrlID;
        private Boolean _CausesValidation;
        private String _Text;
        private String _OnClientScript;

        public CrudDeleteColumnTemplate(String text, String clientScript) {
            Init(text, false, clientScript);
        }
        public CrudDeleteColumnTemplate(String text, Boolean causesValidation, String clientScript) {
            Init(text, causesValidation, clientScript);
        }

        private void Init(String text, Boolean causesValidation, String clientScript) {
            _CtrlID = "_CRUD_GridView_DeleteButton";
            _Text = text;
            _CausesValidation = causesValidation;
            _OnClientScript = clientScript;
        }

        public void InstantiateIn(Control container) {
            LinkButton lb = new LinkButton();
            lb.ID = _CtrlID;
            lb.CausesValidation = _CausesValidation;
            lb.CommandName = "Delete";
            lb.Text = _Text;
            lb.OnClientClick = _OnClientScript;
            container.Controls.Add(lb);
        }

        #endregion
    }
}
